package com.jackchong.net

/**
 * author : chong.huang
* create : 3/22/21
 * desc   :
 */
data class CacheStrategy(var mode: CacheModeEnum, var tag: String? = null) {
    companion object {
        fun AUTO(): CacheStrategy = CacheStrategy(CacheModeEnum.AUTO)
        fun NOT(): CacheStrategy = CacheStrategy(CacheModeEnum.NOT)
        fun TAG(tag: String): CacheStrategy = CacheStrategy(CacheModeEnum.TAG, tag)

        fun obtainTag(): String {
            for (st in Thread.currentThread().stackTrace) {
                if (st.isNativeMethod || st.className == Thread::class.java.name || st.className.contains("com.jackchong")) {
                    continue
                }
                return st.fileName + st.lineNumber
            }
            return ""
        }
    }
}